package demo1;

import java.util.Comparator;

public class NameComparator implements Comparator<Student> {
    @Override
    public int compare(Student o1, Student o2) {
        return o1.name.compareTo(o2.name);//因为name是引用类型，无法直接比较，所以得调用compareTo方法
    }
}
